# -*- coding: utf-8 -*-
"""
Created on Wed Mar 20 15:04:38 2024

@author: Weika
"""

import numpy as np
import os
import glob
import matplotlib.pyplot as plt
from numpy.linalg import norm

# import matplotlib
# matplotlib.rc("font",family='SimSun')

font_label = {
    'family': 'Times New Roman',
    'weight': 'normal',
    'size': 18,
    # 'style': 'italic'  # 使字变斜
 #   'usetex' : True,  # legend 无得设 `usetex` 这项
}
#
# config = {
#     "font.family": "serif",  # 使用衬线体
#     "font.serif": ["SimSun"],  # 全局默认使用衬线宋体
#     "font.size": 18,  # 五号，10.5磅
#     "axes.unicode_minus": False,
#     "mathtext.fontset": "stix",  # 设置 LaTeX 字体，stix 近似于 Times 字体
# }
# plt.rcParams.update(config)


font_legend = {
    'family': 'Times New Roman',
    'weight': 'normal',
    'size': 16,
    # 'style': 'italic'  # 使字变斜
    # 'usetex' : True,  # legend 无得设 `usetex` 这项
}


folder_path='./400'
npy_files=glob.glob(os.path.join(folder_path, '*.npz'))

iteration=4000

dic=dict()
n=0
for npy_file in npy_files:
	variable_name=os.path.splitext(os.path.basename(npy_file))[0]
	dic[n]=variable_name
	globals()[variable_name]=np.load(npy_file)
	
	stable=globals()[dic[n]]['honest_func'][max(i for i,x in enumerate(globals()[dic[n]]['honest_func']) if x > 0)]
	print(stable)
	
	func_value=np.zeros(iteration)
	
	for i,x in enumerate(globals()[dic[n]]['honest_func']): 
		if x > 0:
			func_value[i]=x
			
	func_value[func_value==0]=stable
	
	globals()[variable_name]=func_value
	
	n=n+1

print(dic)

# 1 2 4 5 10 20 25 50 100
# 1 5 25 100
start=0
iteration=4000
iterations=range(start,iteration)




# plt.plot(iterations,globals()[dic[6]][start:iteration],label='L=10')
# plt.plot(iterations,globals()[dic[7]][start:iteration],label='L=20')
# plt.plot(iterations,globals()[dic[10]][start:iteration],label='L=25')
# plt.plot(iterations,globals()[dic[13]][start:iteration],label='L=2')
# plt.plot(iterations,globals()[dic[16]][start:iteration],label='L=4')
# plt.plot(iterations,globals()[dic[18]][start:iteration],label='L=50')
# plt.plot(iterations,globals()[dic[21]][start:iteration],label='L=5')

# plt.plot(iterations,globals()[dic[1]][start:iteration],label='L=100')
# plt.plot(iterations,globals()[dic[3]][start:iteration],label='L=20')
# plt.plot(iterations,globals()[dic[5]][start:iteration],label='L=10')
# plt.plot(iterations,globals()[dic[9]][start:iteration],label='L=25')
# plt.plot(iterations,globals()[dic[12]][start:iteration],label='L=2')
# plt.plot(iterations,globals()[dic[15]][start:iteration],label='L=4')
# plt.plot(iterations,globals()[dic[17]][start:iteration],label='L=50')
# plt.plot(iterations,globals()[dic[20]][start:iteration],label='L=5')

# plt.plot(iterations,globals()[dic[0]][start:iteration],label='L=100')
# plt.plot(iterations,globals()[dic[2]][start:iteration],label='L=20')
# plt.plot(iterations,globals()[dic[4]][start:iteration],label='L=10')
# plt.plot(iterations,globals()[dic[8]][start:iteration],label='L=25')
# plt.plot(iterations,globals()[dic[11]][start:iteration],label='L=2')
# plt.plot(iterations,globals()[dic[14]][start:iteration],label='L=4')
# plt.plot(iterations,globals()[dic[19]][start:iteration],label='L=5')




# # 实验3：1
# plt.figure(figsize=(14/2.54,12/2.54))

# plt.plot(iterations,globals()[dic[2]][start:iteration],label='$u_b$=0.1',color='c',linestyle='-',marker='v',mfc='none',markevery=50)
# plt.plot(iterations,globals()[dic[8]][start:iteration],label='$u_b$=0.3',color='m',linestyle='-',marker='^',mfc='none',markevery=50)
# plt.plot(iterations,globals()[dic[18]][start:iteration],label='$u_b$=0.5',color='y',linestyle='-',marker='s',mfc='none',markevery=50)
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='不存在拜占庭用户',color='b',linestyle='-',marker='o',mfc='none',markevery=50)

# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")

# plt.grid()

# plt.xlim(0,600)
# plt.xticks(np.arange(0,600+1,100),fontproperties='Times New Roman',size=16)
# plt.ylim(281,292)
# plt.yticks(np.arange(281,294,2),fontproperties='Times New Roman',size=16)

# plt.legend(bbox_to_anchor=(0.4,0.3))

# plt.savefig('./cn/robust_L1.pdf',bbox_inches='tight',dpi=300)

# plt.show()




# # 实验3：2
# plt.figure(figsize=(14/2.54,12/2.54))

# plt.plot(iterations,globals()[dic[2]][start:iteration],label='L=1',color='c',linestyle='-',marker='v',mfc='none',markevery=300)
# plt.plot(iterations,globals()[dic[3]][start:iteration],label='L=20',linestyle='--',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[4]][start:iteration],label='L=40',linestyle='-',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[5]][start:iteration],label='L=60',linestyle='--',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[6]][start:iteration],label='L=80',linestyle='-',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[1]][start:iteration],label='L=100',linestyle='--')
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='不存在拜占庭用户',color='b',linestyle='-',marker='o',mfc='none',markevery=300)

# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")

# plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,600),fontproperties='Times New Roman',size=16)
# plt.ylim(281,292)
# plt.yticks(np.arange(281,294,2),fontproperties='Times New Roman',size=16)

# handles,labels=plt.gca().get_legend_handles_labels()
# order=[0,2,4,6,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],ncol=2)

# plt.savefig('./cn/robust_01.pdf',bbox_inches='tight',dpi=300)

# plt.show()




# # 实验3：3
# plt.figure(figsize=(14/2.54,12/2.54))

# plt.plot(iterations,globals()[dic[8]][start:iteration],label='L=1',color='m',linestyle='-',marker='^',mfc='none',markevery=300)
# plt.plot(iterations,globals()[dic[9]][start:iteration],label='L=20',linestyle='--',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[10]][start:iteration],label='L=40',linestyle='-',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[11]][start:iteration],label='L=60',linestyle='--',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[12]][start:iteration],label='L=80',linestyle='-',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[7]][start:iteration],label='L=100',linestyle='--')
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='不存在拜占庭用户',color='b',linestyle='-',marker='o',mfc='none',markevery=300)

# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")

# plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,600),fontproperties='Times New Roman',size=16)
# plt.ylim(281,292)
# plt.yticks(np.arange(281,294,2),fontproperties='Times New Roman',size=16)

# handles,labels=plt.gca().get_legend_handles_labels()
# order=[0,2,4,6,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],ncol=2)

# plt.savefig('./cn/robust_03.pdf',bbox_inches='tight',dpi=300)

# plt.show()




# # 实验3：4
# plt.figure(figsize=(14/2.54,12/2.54))

# plt.plot(iterations,globals()[dic[18]][start:iteration],label='L=1',color='y',linestyle='-',marker='s',mfc='none',markevery=300)
# plt.plot(iterations,globals()[dic[14]][start:iteration],label='L=20',linestyle='--',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[15]][start:iteration],label='L=40',linestyle='-',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[16]][start:iteration],label='L=60',linestyle='--',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[17]][start:iteration],label='L=80',linestyle='-',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[13]][start:iteration],label='L=100',linestyle='--')
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='不存在拜占庭用户',color='b',linestyle='-',marker='o',mfc='none',markevery=300)

# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")

# plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,600),fontproperties='Times New Roman',size=16)
# plt.ylim(281,292)
# plt.yticks(np.arange(281,294,2),fontproperties='Times New Roman',size=16)

# handles,labels=plt.gca().get_legend_handles_labels()
# order=[0,2,4,6,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],ncol=2)

# plt.savefig('./cn/robust_05.pdf',bbox_inches='tight',dpi=300)

# plt.show()




# 实验2：1
# plt.plot(iterations,globals()[dic[7]][start:iteration],label='L=1',linestyle='--',marker='o',markevery=300)
# plt.plot(iterations,globals()[dic[8]][start:iteration],label='L=20',linestyle='-',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[9]][start:iteration],label='L=40',linestyle='--',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[10]][start:iteration],label='L=60',linestyle='-',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[11]][start:iteration],label='L=80',linestyle='--',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[6]][start:iteration],label='L=100',linestyle='-')
# plt.plot(iterations,globals()[dic[1]][start:iteration],label='no Byzantine agents',linestyle='-.',linewidth=2)

# plt.xlabel("Number of iterations $k$",font_label)
# plt.ylabel("Function value $f(\mathbf{v})$",font_label)

# plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,600),fontproperties='Times New Roman',size=16)

# # plt.ylim(281.5,285)
# # plt.yticks(np.arange(281.5,286.6,1),fontproperties='Times New Roman',size=16)
# plt.ylim(120.5,126.5)
# plt.yticks(np.arange(120.5,126.6,1),fontproperties='Times New Roman',size=16)
# # plt.ylim(195.5,202)
# # plt.yticks(np.arange(195,202.1,1),fontproperties='Times New Roman',size=16)

# plt.yticks(fontproperties='Times New Roman',size=16)

# handles,labels=plt.gca().get_legend_handles_labels()
# order=[0,2,4,6,1,3,5]
# # order=[0,2,4,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],prop=font_legend,ncol=2)

# # plt.savefig('./fig/convergence_500.pdf',bbox_inches ='tight',dpi=300)
# plt.savefig('./fig/robust_30_05_100.pdf',bbox_inches='tight',dpi=300)

# plt.show()



# 实验2：2
plt.plot(iterations,globals()[dic[0]][start:iteration],label='base',linestyle='--',marker='o',markevery=300)
plt.plot(iterations,globals()[dic[1]][start:iteration],label='L=1',linestyle='-',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[2]][start:iteration],label='L=80 ',linestyle='--',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[3]][start:iteration],label='L=60',linestyle='-',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[4]][start:iteration],label='L=80',linestyle='--',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[5]][start:iteration],label='L=100',linestyle='-')
# plt.plot(iterations,globals()[dic[6]][start:iteration],label='no Byzantine agents',linestyle='-.',linewidth=2)

plt.xlabel("Number of iterations $k$",font_label)
plt.ylabel("Function value $f(\mathbf{v})$",font_label)

plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,600),fontproperties='Times New Roman',size=16)
#
plt.ylim(0,800)
plt.yticks(np.arange(360,371,2),fontproperties='Times New Roman',size=16)
# # plt.ylim(120.5,126.5)
# # plt.yticks(np.arange(120.5,126.6,1),fontproperties='Times New Roman',size=16)
# # plt.ylim(195.5,202)
# # plt.yticks(np.arange(195,202.1,1),fontproperties='Times New Roman',size=16)
#
# plt.yticks(fontproperties='Times New Roman',size=16)
#
# handles,labels=plt.gca().get_legend_handles_labels()
# order=[0,2,4,6,1,3,5]
# # order=[0,2,4,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],prop=font_legend,ncol=2)
plt.legend()

# plt.savefig('./fig/convergence_500.pdf',bbpox_inches ='tight',dpi=300)
plt.savefig('./fig/robust_400.pdf',bbox_inches='tight',dpi=300)

plt.show()



# # 实验2：3
# plt.figure(figsize=(14/2.54,12/2.54))

# plt.plot(iterations,globals()[dic[1]][start:iteration],label='L=1',linestyle='--',marker='o',markevery=300)
# plt.plot(iterations,globals()[dic[2]][start:iteration],label='L=20',linestyle='-',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[3]][start:iteration],label='L=40',linestyle='--',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[4]][start:iteration],label='L=60',linestyle='-',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[5]][start:iteration],label='L=80',linestyle='--',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='L=100',linestyle='-')
# # plt.plot(iterations,globals()[dic[0]][start:iteration],label='no Byzantine agents',linestyle='-.',linewidth=2)

# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")

# plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,200),fontproperties='Times New Roman',size=16)

# # plt.ylim(281.5,285)
# # plt.yticks(np.arange(281.5,286.6,1),fontproperties='Times New Roman',size=16)
# # plt.ylim(29.5,33.5)
# # plt.yticks(np.arange(29.5,33.6,1),fontproperties='Times New Roman',size=16)
# plt.ylim(195.5,202)
# plt.yticks(np.arange(195,202.1,1),fontproperties='Times New Roman',size=16)

# plt.yticks(fontproperties='Times New Roman',size=16)

# handles,labels=plt.gca().get_legend_handles_labels()
# # order=[0,2,4,6,1,3,5]
# order=[0,2,4,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],ncol=2)

# plt.savefig('./cn/convergence_500.pdf',bbox_inches ='tight',dpi=300)
# # plt.savefig('./fig/robust_30_05_500.pdf',bbox_inches='tight',dpi=300)

# plt.show()




# # 实验2：4
# plt.figure(figsize=(14/2.54,12/2.54))

# plt.plot(iterations,globals()[dic[2]][start:iteration],label='L=1',linestyle='--',marker='o',markevery=300)
# plt.plot(iterations,globals()[dic[3]][start:iteration],label='L=20',linestyle='-',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[4]][start:iteration],label='L=40',linestyle='--',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[5]][start:iteration],label='L=60',linestyle='-',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[6]][start:iteration],label='L=80',linestyle='--',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[1]][start:iteration],label='L=100',linestyle='-')
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='不存在拜占庭用户',linestyle='-.',linewidth=2)

# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")

# plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,600),fontproperties='Times New Roman',size=16)

# # plt.ylim(281.5,285)
# # plt.yticks(np.arange(281.5,286.6,1),fontproperties='Times New Roman',size=16)
# plt.ylim(138,150)
# plt.yticks(np.arange(138,150+1,2),fontproperties='Times New Roman',size=16)
# # plt.ylim(195.5,202)
# # plt.yticks(np.arange(195,202.1,1),fontproperties='Times New Roman',size=16)

# plt.yticks(fontproperties='Times New Roman',size=16)

# handles,labels=plt.gca().get_legend_handles_labels()
# order=[0,2,4,6,1,3,5]
# # order=[0,2,4,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],ncol=2)

# # plt.savefig('./fig/convergence_500.pdf',bbox_inches ='tight',dpi=300)
# plt.savefig('./cn/robust_30_05_1000.pdf',bbox_inches='tight',dpi=300)

# plt.show()



# # 实验1：2
# plt.figure(figsize=(14/2.54,12/2.54))

# plt.plot(iterations,globals()[dic[2]][start:iteration],label='L=1',linestyle='--',marker='o',markevery=100)
# plt.plot(iterations,globals()[dic[3]][start:iteration],label='L=20',linestyle='-',marker='<',markevery=100)
# plt.plot(iterations,globals()[dic[4]][start:iteration],label='L=40',linestyle='--',marker='>',markevery=100)
# plt.plot(iterations,globals()[dic[5]][start:iteration],label='L=60',linestyle='-',marker='x',markevery=100)
# plt.plot(iterations,globals()[dic[6]][start:iteration],label='L=80',linestyle='--',marker='d',markevery=100)
# plt.plot(iterations,globals()[dic[1]][start:iteration],label='L=100',linestyle='-')
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='不存在拜占庭用户',linestyle='-.',linewidth=2)

# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")

# plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,200),fontproperties='Times New Roman',size=16)

# # plt.ylim(281.5,285)
# # plt.yticks(np.arange(281.5,286.6,1),fontproperties='Times New Roman',size=16)
# # plt.ylim(120.6,122.2)
# # plt.yticks(np.arange(120.6,122.2,0.4),fontproperties='Times New Roman',size=16)
# # plt.ylim(195.5,202)
# # plt.yticks(np.arange(195,202.1,1),fontproperties='Times New Roman',size=16)

# plt.yticks(fontproperties='Times New Roman',size=16)

# handles,labels=plt.gca().get_legend_handles_labels()
# order=[0,2,4,6,1,3,5]
# # order=[0,2,4,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],ncol=2)

# # plt.savefig('./fig/convergence_500.pdf',bbox_inches ='tight',dpi=300)
# plt.savefig('./cn/robust0_10_03_100.pdf',bbox_inches='tight',dpi=300)

# plt.show()




# # 实验1：3
# plt.figure(figsize=(14/2.54,12/2.54))

# plt.plot(iterations,globals()[dic[1]][start:iteration],label='L=1',linestyle='--',marker='o',markevery=300)
# plt.plot(iterations,globals()[dic[2]][start:iteration],label='L=20',linestyle='-',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[3]][start:iteration],label='L=40',linestyle='--',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[4]][start:iteration],label='L=60',linestyle='-',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[5]][start:iteration],label='L=80',linestyle='--',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='L=100',linestyle='-')
# # plt.plot(iterations,globals()[dic[0]][start:iteration],label='no Byzantine agents',linestyle='-.',linewidth=2)

# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")

# plt.grid()

# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,200),fontproperties='Times New Roman',size=16)

# # plt.ylim(281.5,285)
# # plt.yticks(np.arange(281.5,286.6,1),fontproperties='Times New Roman',size=16)
# plt.ylim(120.6,122.2)
# plt.yticks(np.arange(120.6,122.2,0.4),fontproperties='Times New Roman',size=16)
# # plt.ylim(195.5,202)
# # plt.yticks(np.arange(195,202.1,1),fontproperties='Times New Roman',size=16)

# plt.yticks(fontproperties='Times New Roman',size=16)

# handles,labels=plt.gca().get_legend_handles_labels()
# # order=[0,2,4,6,1,3,5]
# order=[0,2,4,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],ncol=2)

# plt.savefig('./cn/convergence_100.pdf',bbox_inches ='tight',dpi=300)
# # plt.savefig('./fig/robust10_10_03_100.pdf',bbox_inches='tight',dpi=300)

# plt.show()




# 实验5：1
# plt.figure(figsize=(14/2.54,12/2.54))
#
# plt.plot(iterations,globals()[dic[1]][start:iteration],label='L=1$,|{\mathbb{B}_A}|$=10',linestyle='--',marker='o',markevery=300)
# plt.plot(iterations,globals()[dic[2]][start:iteration],label='L=20$,|{\mathbb{B}_A}|$=10',linestyle='-',marker='<',markevery=300)
# plt.plot(iterations,globals()[dic[3]][start:iteration],label='L=1$,|{\mathbb{B}_A}|$=20',linestyle='--',marker='>',markevery=300)
# plt.plot(iterations,globals()[dic[4]][start:iteration],label='L=20$,|{\mathbb{B}_A}|$=20',linestyle='-',marker='x',markevery=300)
# plt.plot(iterations,globals()[dic[5]][start:iteration],label='L=1$,|{\mathbb{B}_A}|$=30',linestyle='--',marker='d',markevery=300)
# plt.plot(iterations,globals()[dic[6]][start:iteration],label='L=20$,|{\mathbb{B}_A}|$=30',linestyle='-')
# plt.plot(iterations,globals()[dic[0]][start:iteration],label='不存在拜占庭用户',linestyle='-.',linewidth=2)
#
#
# plt.xlabel("迭代次数 $k$")
# plt.ylabel("总成本函数 $f(\mathbf{v})$")
#
# plt.grid()
#
# plt.xlim(0,iteration)
# plt.xticks(np.arange(0,iteration+1,600),fontproperties='Times New Roman',size=16)
#
# # plt.ylim(281.5,285)
# # plt.yticks(np.arange(281.5,286.6,1),fontproperties='Times New Roman',size=16)
# # plt.ylim(138,150)
# # plt.yticks(np.arange(138,150+1,2),fontproperties='Times New Roman',size=16)
# plt.ylim(120.6,122.1)
# plt.yticks(np.arange(120.6,122.2,0.3),fontproperties='Times New Roman',size=16)
#
# plt.yticks(fontproperties='Times New Roman',size=16)
#
# handles,labels=plt.gca().get_legend_handles_labels()
# order=[0,2,4,6,1,3,5]
# # order=[0,2,4,1,3,5]
# plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order],ncol=2,loc='lower center',bbox_to_anchor=(0.5, 1),fancybox=True)
#
# # plt.savefig('./fig/convergence_500.pdf',bbox_inches ='tight',dpi=300)
# plt.savefig('./cn/robust_10_20_30_01_100.pdf',bbox_inches='tight',dpi=300)






# 收敛性 
# K_f=100,300,500 L=1,20,40,60,80,100
# 鲁棒性 
# 无robust aggretion rule的影响 b=0 K_f=100 B=10 u_b=0.3 L=1,20,40,60,80,100 

# 有robust aggretion rule的影响 b=B K_f=100,300,500 B=30 u_b=0.5 L=1,20,40,60,80,100

# 有robust aggretion rule的影响 b=B K_f=100,300,500 B=30 u_b=0.5 L=1,2,4,5,10,20,25,50,100

# 有robust aggretion rule的影响 b=B K_f=300, B=30 u_b=0.1,0.3.0.5 L=1,20,40,60,80,100

# 有robust aggretion rule的影响 b=B K_f=300, B=30,20,10 u_b=0.3 L=1,20,40,60,80,100